﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UT3Bots.Communications;


namespace UT3Bots.UTItems
{
	public class UTBotOppState : UTBotState
	{
		//Opponent state variables
		private bool _isReachable;
		private int _ammoCount;
		private string _lastChatMessage = "";
		private DateTime _lastUpdated;

		#region Properties

		/// <summary>
		/// True if you can reach this bot, false if there is something between you (eg. A Pit)
		/// </summary>
		public bool IsReachable
		{
			get
			{
				return this._isReachable;
			}
		}

		internal int CurrentAmmo
		{
			get
			{
				return this._ammoCount;
			}
			set
			{
				this._ammoCount = value;
				OnPropertyChanged("CurrentAmmo");
			}
		}

		internal string LastChatMessage
		{
			get
			{
				return this._lastChatMessage;
			}
			set
			{
				this._lastChatMessage = value;
				OnPropertyChanged("LastChatMessage");
			}
		}

		internal DateTime LastUpdated
		{
			get
			{
				return this._lastUpdated;
			}
			set
			{
				this._lastUpdated = value;
				OnPropertyChanged("LastUpdated");
			}
		}
		#endregion


		internal UTBotOppState(Message Msg)
			: base()
		{
			if (Msg.Info == InfoMessage.PLAYER_INFO)
			{
				this._id = new UTIdentifier(Msg.Arguments[0]);
				this._location = UTVector.Parse(Msg.Arguments[1]);
				this._rotation = UTVector.Parse(Msg.Arguments[2]);
				this._velocity = UTVector.Parse(Msg.Arguments[3]);
				this._name = Msg.Arguments[4];
				this._health = int.Parse(Msg.Arguments[5]);
				this._armor = int.Parse(Msg.Arguments[6]);
				this._weapon = Msg.Arguments[7].GetAsWeaponType();
				this._firingType = (FireType)(int.Parse(Msg.Arguments[8]));
				this._mesh = (BotMesh)(int.Parse(Msg.Arguments[9]));
				this._colour = (BotColor)(int.Parse(Msg.Arguments[10]));
				this._isReachable = bool.Parse(Msg.Arguments[11]);

				if (Msg.Arguments.Length > 12)
				{
					this._ammoCount = int.Parse(Msg.Arguments[12]);
				}
			}
		}


	}
}
